<?php
# PLEASE DO NOT MODIFY THIS WITHOUT READING THE INSTRUCTIONS
# NEVER TOUCH SECTION MARKED AS "DO NOT CHANGE" Line 7 to END
# CHANGE ONLY SECTION MARKED AS "CHANGE   ONLY YOUR SECTION" Line 39 TO "END OF : CHANGE  ONLY YOUR SECTION"
# BUT YOUR SECTION ONLY. e.i ONLY THE FUNCTIOS CREATED BY YOU

	include "class_BOU.php";

	################################   DO NOT CHANGE   #################################
	$m_date= date("d-m-y");
	//Get All http values
	$IN_MSG_ID = $_GET['IN_MSG_ID'];
	$MOBILENO = $_GET['MOBILENO'];
	$BODY = $_GET['BODY'];
	$ORIGIN_PORT = $_GET['ORIGIN_PORT'];	
	$your_out_msg_id = 1234567;
	
	//echo $IN_MSG_ID."<br>". $MOBILENO."<br>".$BODY."<br>".$ORIGIN_PORT."<br>".$your_out_msg_id."<br>";
	//Create the object with the necessary values
	$obj = new bou($IN_MSG_ID, $MOBILENO, $BODY, $ORIGIN_PORT, $your_out_msg_id);
	$obj->MySQL();

	$SQL="INSERT INTO msgbox (id,Phn_no,msg,m_date) VALUES ('','$MOBILENO', '$BODY','$m_date')";	
	//echo $SQL;
	$obj->sql($SQL);	

	ProcessMsg($obj);

	##############################   CHANGE   ONLY YOUR SECTION  ########################
	function ProcessMsg($obj)
	{
		
		if($obj->IN_MSG_ID)
		{			
			$msg= trim($obj->BODY);
			$mg = explode(" ", $msg);
			$wrd= substr($msg,6);		
			//$wrd= $mg[2];
			$msg=  $obj->BODY;							
			$mg[0]=strtoupper($mg[0]);
			$mg[1]=strtoupper($mg[1]);


			if($mg[0] == 'BOU')
			{	
				################ CHANGE   ONLY YOUR SECTION ######################
				switch($mg[1])
				{
					/* 			IMRAN		*/ 
					case 'D':
						
						$obj->dictionary($wrd);
						//Call XML portion
						$obj->xml();		
						break;
					/* 			IMRAN		*/ 	
					case 'P':
						$obj->feedBack($wrd);
						//Call XML portion
						$obj->xml();		
						break;
					case 'G':
						$obj->rules();
						//Call XML portion
						//$obj->xml();		
						break;	
					
					case 'T':
						$obj->schedule();
						//Call XML portion
						//$obj->xml();		
						break;	
					
					case 'Y':
						$obj->attn($wrd);
							
						break;
						
					case 'H': $obj->homework($wrd);
					break;	
					
					
					case 'Q2A':
					case 'Q2B':
					case 'Q2C':
					case 'Q2D': $obj->que($mg[1]);
					break;
					
					case 'Z': if (is_numeric($wrd))
								{
					
								$obj->question($wrd);
								break;
								}
								else
								{
								$obj->answer($wrd);
								break;
								}	
						/* */
					default : $obj->sms="invalid format";
							//Call XML portion
							$obj->xml();		
					break;
				}
				################ END OF : CHANGE  ONLY YOUR SECTION ##############			
			}
			else {
				$obj->sms="invalid format";
		
				//Call XML portion
				$obj->xml();		
				}
		}else{
			echo '<b>request example url</b>: ?IN_MSG_ID=11254&MOBILENO=8801711505676&BODY=Test Message&ORIGIN_PORT=2000';
		}
		
	}
	##############################         END             ########################
?>